home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / theprn09.zip / DEMO.BAS < prev    next >
BASIC Source File  |  1992-07-06  |  3KB  |  102 lines

  1.  
  2. DEFINT A-Z
  3.  
  4. '    Name:       Demo.Bas
  5. '
  6. ' Purpose:       * Demonstrate reading printer records.
  7. '
  8. '                * Demonstrate using TYPE.INC (and when not to).
  9. '
  10. '                * Show how one might display printer codes.
  11. '
  12. '                  Something like this might be used inside a
  13. '                  program to show users which codes are
  14. '                  available (ie., not blank) and perhaps what
  15. '                  they should do to invoke each option.
  16. '
  17. '    NOTE:       Some printer codes may contain control codes which
  18. '                will screw up the display.  Try a different printer.
  19. '                And in your own programs you might want to use an ASM
  20. '                "quickprint" routine to overcome this problem.
  21. '
  22. '
  23. '  Author:       Copyright 1992, Rob W. Smetana  All Rights Reserved
  24. '                To be distributed only with The Printer.
  25. '
  26. 'Requires:       BEFORE running this, you MUST run Printer.Exe, select a
  27. '                printer, and press F2 to SAVE Printer.Cfg.  This program
  28. '                will display the contents of Printer.Cfg.
  29.  
  30.  
  31.  
  32. '...include two TYPES useful for reading printer codes.
  33.  
  34. '$INCLUDE: 'Type.Inc'
  35.  
  36.  
  37. '...NOTE:  Although we loaded a TYPE called Printer, we won't use it!
  38. '   For what we're about to do, it's more code efficient to read stuff
  39. '   using some simple 980-byte strings.
  40.  
  41. Labels$ = SPACE$(980)
  42. Codes$ = Labels$
  43.  
  44.  
  45. OPEN "Printer.Cfg" FOR BINARY AS #1         '...this MUST already exist!!!
  46.  
  47.     GET #1, , Header                        '...we WILL use the header
  48.  
  49.     GET #1, , Labels$                       '...To print descriptions
  50.  
  51.     GET #1, , Header                        '...Get again so we're in position
  52.                                             '   to read codes.
  53.                                              
  54.     GET #1, , Codes$                        '...To display printer codes
  55.  
  56. CLOSE
  57.  
  58. '...Now display 'em
  59.  
  60. COLOR , 1: CLS
  61.  
  62. PRINT "   You chose a printer made by :  "; Header.Manufacturer;
  63. PRINT "                  The Model is :  "; Header.Model
  64.  
  65. IF LEN(RTRIM$(Header.EmMode)) THEN       '...if it's emulating another ...
  66.  
  67.     PRINT "     This printer is emulating :  "; RTRIM$(Header.EmMode); " printer."
  68.     It.Is.Emulating = -1
  69.  
  70. END IF
  71.  
  72. PRINT : PRINT
  73.  
  74. '...Now for the codes
  75.  
  76. FOR x = 1 TO 70
  77.  
  78.     '...Starting at column 1 of Labels$, print 70, 14-byte fields.
  79.  
  80.     Where = 1 + ((x - 1) * 14)          '...Where = 1 for code #1
  81.  
  82.  
  83.     '...Printing this way is simpler than printing separate TYPE members.
  84.  
  85.     PRINT "     "; MID$(Labels$, Where, 14); "   "; MID$(Codes$, Where, 14),
  86.  
  87.  
  88.     '...They won't all fit on 1 screen, so pause, then display the rest.
  89.  
  90.     IF CSRLIN > 22 AND x < 70 THEN
  91.  
  92.        LOCATE 25, 20: PRINT "Press any key to see the rest . . .";
  93.        d$ = INPUT$(1)
  94.  
  95.        LOCATE 5, 1
  96.        IF It.Is.Emulating = False THEN PRINT
  97.  
  98.     END IF
  99.  
  100. NEXT
  101.  
  102.